package com.leetcode.LC;

public class LC941 {
    public boolean validMountainArray(int[] arr) {

        if (arr.length < 3) {
            return false;
        }

        //双指针
        int a = 0, b = arr.length - 1, count = 2;

        while (count++ < arr.length) {
            if (a + 1 < arr.length && arr[a] < arr[a + 1]) {
                a++;
            }
            if (b - 1 >= 0 && arr[b - 1] > arr[b]) {
                b--;
            }
        }
        if (a == b) {
            return true;
        } else {
            return false;
        }

    }

    public static void main(String[] args) {
        System.out.println(new LC941().validMountainArray(new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 7}));
    }

}
